﻿using System.Collections.Generic;
using PerceptiveMCAPI.Types;
//
namespace PerceptiveMCAPI
{
   internal static class listWebhookAdd_Validator
   {
      // webhook_actions
      internal static Api_ValidatorMessage actions_valid( Dictionary<EnumValues.listWebhookActions, bool> dictionary )
      {
         // must be at least one action
         if ( dictionary.Count < 1 )
            return Validator.FormatMsg( EnumValues.MessageLevel.Error, "actions", "No actions defined. At least one action is required" );
         // can't have a 'NotSpecified' entry
         foreach ( KeyValuePair<EnumValues.listWebhookActions, bool> action in dictionary )
         {
            if ( action.Key == EnumValues.listWebhookActions.NotSpecified )
            {
               return Validator.FormatMsg( EnumValues.MessageLevel.Error, "actions", "Action was not specified for one or more entries." );
            }
         }
         return null;
      }
      // webhook_sources
      internal static Api_ValidatorMessage sources_valid( Dictionary<EnumValues.listWebhookSources, bool> dictionary )
      {
         // must be at least one action
         if ( dictionary.Count < 1 )
            return Validator.FormatMsg( EnumValues.MessageLevel.Error, "sources", "No sources defined. At least one source is required" );
         // can't have a 'NotSpecified' entry
         foreach ( KeyValuePair<EnumValues.listWebhookSources, bool> source in dictionary )
         {
            if ( source.Key == EnumValues.listWebhookSources.NotSpecified )
            {
               return Validator.FormatMsg( EnumValues.MessageLevel.Error, "sources", "Source was not specified for one or more entries." );
            }
         }
         return null;
      }
   }
}
